<template>
    <div>
        <Row style="line-height: 35px;">
            <Col span='2'>
                <b>基础信息</b>
            </Col>
            <Col span='9' offset="1">
                <span>一级风险单元：{{InputData.saRiskInfo.riskUnitName}}</span>
            </Col>
            <Col span='9' offset="1">
                <span>二级风险单元：{{InputData.saRiskInfo.riskUnit2}}</span>
            </Col>
        </Row>
        <Row style="line-height: 35px" class="detail-background-clor">
            <Col span='9' offset="3">
                <span>三级风险单元：{{InputData.saRiskInfo.riskUnit3}}</span>
            </Col>
            <Col span='9' offset="1">
                <span>四级风险单元：{{InputData.saRiskInfo.riskUnit4}}</span>
            </Col>
        </Row>
        <Row style="line-height: 35px">
            <Col span='9' offset="3">
                <span>设备设施名称：{{InputData.saRiskInfo.equipmentName}}</span>
            </Col>
            <Col span='9' offset="1">
                <span>子系统单元或重要元器件：{{InputData.saRiskInfo.subEqName}}</span>
            </Col>
        </Row>
        <Row style="line-height: 35px" class="detail-background-clor">
            <Col span='9' offset="3">
                <span>风险类别：{{InputData.saRiskInfo.riskTypeName}}</span>
            </Col>
            <Col span='9' offset="1">
                <span>风险识别维度：{{InputData.saRiskInfo.rikDiscernName}}</span>
            </Col>
        </Row>
        <Row style="line-height: 35px">
            <Col span='20' offset="3">
                <span>风险描述：{{InputData.saRiskInfo.riskDesc}}</span>
            </Col>
        </Row>
        <hr style="margin-top: 10px;color: #dcdcdc"/>
        <Row style="line-height: 25px;margin-top: 10px">
            <Col span='2'>
                <b>风险评价</b>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='后果程度C1：' prop="c1">
                    <Select v-model="InputData.c1">
                        <Option v-for="item in c1List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='系统影响程度C2：' prop="c2">
                    <Select v-model="InputData.c2">
                        <Option v-for="item in c2List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='发生概率C3：' prop="c3">
                    <Select v-model="InputData.c3">
                        <Option v-for="item in c3List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="3">
                <FormItem label='防止故障的难易程度C4：' prop="c4">
                    <Select v-model="InputData.c4">
                        <Option v-for="item in c4List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='是否为新设计系统C5：' prop="c5">
                    <Select v-model="InputData.c5">
                        <Option v-for="item in c5List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
        </Row>
        <Row style="line-height: 25px;margin-top: 10px">
            <Col span='6' offset="3">
                <span>评点数Cs：{{resultComputed}}</span>
            </Col>
            <Col span='6' offset="1">
                <span>风险等级R：{{InputData.rikRankName}}</span>
            </Col>
            <Col span='6' offset="1">
                        <span>风险警示色：
                            <span v-if="InputData.rikColor=='红'" style="color: red">{{InputData.rikColor}}</span>
                            <span v-else-if="InputData.rikColor=='橙'"
                                  style="color: orange">{{InputData.rikColor}}</span>
                            <span v-else-if="InputData.rikColor=='黄'"
                                  style="color: #FDD835">{{InputData.rikColor}}</span>
                            <span v-else-if="InputData.rikColor=='蓝'" style="color: blue">{{InputData.rikColor}}</span>
                            <span v-else style="color: white">{{InputData.rikColor}}</span>
                        </span>
            </Col>
        </Row>
        <hr style="margin-top: 10px;color: #dcdcdc"/>
        <Row style="line-height: 25px;margin-top: 10px">
            <Col span='2'>
                <b>风险管控</b>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='风险防范措施(技术、管理、教育)：' prop="manageMeasure">
                    <Input v-model="InputData.saRiskManage.manageMeasure"/>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='应急措施(救治、处置)：' prop="emerMearsure">
                    <Input v-model="InputData.saRiskManage.emerMearsure"/>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='责任部门：' prop="dutyOrgName"><!-- dutyOrgId -->
                    <Input v-model="InputData.saRiskManage.dutyOrgName"/>
                  <!--  <cascaderDom ref="childOrg" @setOrgInfo="setOrgId" @setOrgname="setOrgName"
                                 :currentOrgId="InputData.saRiskManage.dutyOrgId"
                                 :currentOrgName="InputData.saRiskManage.dutyOrgName"
                                 :orgTree="true"></cascaderDom>-->
                </FormItem>
            </Col>
            <Col span='6' offset="3">
                <FormItem label='责任人：' prop="dutyPersonName"><!--dutyPersonId-->
                   <!-- <cascaderDom ref="childUser1" @setOrgInfo="setUserId" @setOrgname="setUserName"
                                 :currentOrgId="InputData.saRiskManage.dutyPersonId"
                                 :currentOrgName="InputData.saRiskManage.dutyPersonName">
                    </cascaderDom>-->
                    <Input v-model="InputData.saRiskManage.dutyPersonName"/>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='关注层面：' prop="focusAspect">
                    <Input v-model="InputData.saRiskManage.focusAspect"/>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='关注周期：' prop="focusCycle">
                    <Input v-model="InputData.saRiskManage.focusCycle"/>
                </FormItem>
            </Col>
            <Col span='6' offset="3">
                <FormItem label='审核人：' prop="checker">
                    <!--<Input v-model="InputData.saRiskAssess.checker"/>-->
                  <!--  <cascaderDom ref="childUser" @setOrgInfo="setUserId1" @setOrgname="setUserName1"
                                 :currentOrgId="InputData.saRiskAssess.checker"
                                 :currentOrgName="InputData.saRiskAssess.checkerName">

                    </cascaderDom>-->
                    <Select
                            v-model="InputData.saRiskAssess.checker"
                            filterable
                            :remote-method="remoteMethod1"
                            :loading="loading1">
                        <Option v-for="(option, index) in options1" :value="option.userId"
                                :label="option.userName" :key="index">
                            <span>{{option.userName}}</span>
                            <span style="float:right;color:#ccc">{{option.orgInfo.orgName}}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='录入人：'>
                    {{InputData.saRiskManage.recorder}}
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='录入时间：'>
                    {{InputData.saRiskManage.recordeTime}}
                </FormItem>
            </Col>
        </Row>
    </div>
</template>

<script>
    import cascaderDom from '../../../../components/cascader-dom.vue';
    import {Api} from '../../../../api/index.js'
    import {sessionStorage} from '../../../../common/cacheUtils.js';
    export default {
        components: {cascaderDom},
        props: ['InputData','model1','options1'],
        name: "equipmentFacilitiesRiskApproval",
        data(){
            return{
                c1List: [
                    {id: 0.5, name: '无功能损失'},
                    {id: 1, name: '原件功能损失'},
                    {id: 3, name: '一定程度损失'},
                    {id: 5, name: '生命财产损失'},
                ],
                c2List: [
                    {id: 0.5, name: '对系统无过大影响'},
                    {id: 1, name: '对系统产生一处以上重大影响'},
                    {id: 2, name: '对系统产生两处以上重大影响'},
                ],
                c3List: [
                    {id: 0.7, name: '不大可能发生'},
                    {id: 1, name: '偶然发生'},
                    {id: 1.5, name: '很可能发生'},
                ],
                c4List: [
                    {id: 0.7, name: '易于防止'},
                    {id: 1, name: '能够防止'},
                    {id: 1.3, name: '无法防止'},
                ],
                c5List: [
                    {id: 0.8, name: '与过去同样的设计'},
                    {id: 1, name: '与过去类似的设计'},
                    {id: 1.2, name: '相当新设计'},
                ],
                loading1:false
            }
        },
        watch: {
            "model1": function (qw, er) {
                if (qw && this.model1) {
                    setTimeout(() => {
                        this.$refs.childOrg.setCurrentOrg();
                        this.$refs.childUser.setCurrentOrg();
                        this.$refs.childUser1.setCurrentOrg();
                    }, 100);
                } else {
                    this.$refs.childOrg.resetCurrentOrg();
                    this.$refs.childUser.resetCurrentOrg();
                    this.$refs.childUser1.resetCurrentOrg();
                }
            },
        },
        computed: {
            resultComputed: function () {
                let cs = 0
                if (this.InputData.c1 > 0 && this.InputData.c2 > 0 && this.InputData.c3 > 0 && this.InputData.c4 > 0 && this.InputData.c5 > 0) {
                    cs = this.NumberMul(this.NumberMul(this.NumberMul(this.NumberMul(this.InputData.c1, this.InputData.c2), this.InputData.c3), this.InputData.c4), this.InputData.c5)
                }
                let rikRan = ' '
                let rikColor = ' '
                this.InputData.cs = cs > 0 ? cs : ' ';
                rikRan = cs > 7 ? '重大' : cs > 1 ? '较大' : cs >= 0.2 ? '一般' : cs > 0 ? '低' : ' ';
                rikColor = cs > 7 ? '红' : cs > 1 ? '橙' : cs >= 0.2 ? '黄' : cs > 0 ? '蓝' : ' ';
                this.InputData.rikRankName = rikRan;
                this.InputData.rikColor = rikColor
                this.InputData.saRiskAssess.rikColor = rikColor
                return this.InputData.cs;
            }
        },
        methods:{
            remoteMethod1(query) {
                if (query !== '') {
                    clearTimeout(this.remoteMethod1.timer);
                    this.remoteMethod1.timer = setTimeout(() => {
                        this.options1.splice(0, this.options1.length);
                        this.loading1 = true;
                        let data = {
                            userName: query,
                            orgId: sessionStorage('userId').getObject('userId').orgInfo.parentId
                        };
                        this.$http.get(Api.queryUserByUserName, {params: data}).then((res) => {
                            this.loading1 = false;
                            res.data.data.forEach(item => {
                                this.options1.push(item);
                            })

                        }).catch(e => {
                            this.loading1 = false;
                        })
                    }, 200);
                } else {
                    this.options1 = [];
                }
            },
            setOrgId(data) {
                this.InputData.saRiskManage.dutyOrgId = data[data.length - 1];
            },
            setOrgName(data) {
                this.InputData.saRiskManage.dutyOrgName = data;
            },
            setUserName(data) {
                this.InputData.saRiskManage.dutyPersonName = data;
            },
            setUserId(data) {
                this.InputData.saRiskManage.dutyPersonId = data[data.length - 1];
            },
            setUserName1(data) {
                this.InputData.saRiskAssess.checkerName = data;
            },
            setUserId1(data) {
                this.InputData.saRiskAssess.checker = data[data.length - 1];
            },
        }
    }
</script>

<style scoped>

</style>
